package gw.com.android.ui.gesture_pwd;


import android.widget.TextView;

import com.gwtsz.gts2.hx.R;

import butterknife.BindView;
import gw.com.android.presenter.PresenterImpl;
import gw.com.android.ui.gesture_pwd.base.GestureBaseActivity;
import gw.com.android.ui.gesture_pwd.custom.EasyGestureLockLayout;
import www.com.library.dialog.ToastPopWindow;

/**
 * 手势密码 登录校验界面
 */
public class GesturePwdCheckActivity extends GestureBaseActivity implements PresenterImpl {

    @BindView(R.id.tv_go)
    TextView tv_go;
    @BindView(R.id.layout_parent)
    EasyGestureLockLayout layout_parent;


    @Override
    public void onRequestSuc(Object result) {

    }

    @Override
    public void onRequestFail(int failCode) {

    }

    @Override
    public void onBackPressed() {
        //这里不接受back按键
        animate(tv_go);
    }

    @Override
    protected int getLayoutView() {
        return R.layout.layout_gesture_pwd_check;
    }

    @Override
    protected void initLayoutView() {

        EasyGestureLockLayout.GestureEventCallbackAdapter adapter = new EasyGestureLockLayout.GestureEventCallbackAdapter() {
            @Override
            public void onCheckFinish(boolean succeedOrFailed) {
                String str = succeedOrFailed ? "解锁成功" : "解锁失败";
                new ToastPopWindow(GesturePwdCheckActivity.this, str).show();
                if (succeedOrFailed) {//如果解锁成功，则finish
                    finish();
                } else {
                    //如果解锁失败
                    //则强制退出登录，跳转至【登录页】，且清空密码
                    //TODO
                    onCheckFailed();
                }
            }

            @Override
            public void onSwipeMore() {
                //执行动画
                animate(tv_go);
            }

            @Override
            public void onToast(String s, int textColor) {
                tv_go.setText(s);
                if (textColor != 0)
                    tv_go.setTextColor(textColor);
                if (textColor == 0xffFF3232) {
                    animate(tv_go);
                }
            }
        };
        layout_parent.setGestureFinishedCallback(adapter);

        //使用check模式
        layout_parent.switchToCheckMode(parsePwdStr(getPwd()), 5);//校验密码
    }

    @Override
    protected void initViewData() {
    }

}
